#include<iostream>
using namespace std;
#include<unistd.h>
#include<sys/types.h>
#include<vector>



void subProcessRun()
{
    while(true)
    {
        cout<<"i am sub process,pid:"<<getpid()<<",ppid:"<<getppid()<<endl;
        sleep(5);
    }
}

int main()
{
    vector<pid_t> allchild;

    for(int i = 0;i<10;i++)
    {
        pid_t id = fork();
        if(id == 0)
        {
            subProcessRun();
        }
        allchild.push_back(id);
    }

    cout<<"children:";
    for(auto child:allchild)
    {
        cout<< child<<" ";
    }
    cout<<endl;

    sleep(10);
    while(true)
    {
        cout<<"i am fprocess,pid:"<<getpid()<<endl;
        sleep(1);
    }

    return 0;
}
